require 'fileutils'

# Workaround a problem with script/plugin and http-based repos.
# See http://dev.rubyonrails.org/ticket/8189
Dir.chdir(Dir.getwd.sub(/vendor.*/, '')) do

  def copy_files(source_path, destination_path, directory)
    source, destination = File.join(directory, source_path), destination_path
    FileUtils.mkdir(destination) unless File.exist?(destination)
    puts "source_path: #{source}, destination: #{destination}"
    FileUtils.cp_r(Dir.glob(source+'/*.*'), destination)
  end

  directory = File.dirname(__FILE__)
  copy_files("/public",  "./public", directory)
  copy_files("/public/javascripts",  "./public/javascripts", directory)
end